﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SilverlightMediaFramework.Core;

namespace OntoWPFSilverlight.Widget
{
    //[OntoWPFSilverlight.Annotation.Widget("VideoViewer")]
    public class MediaViewer : DockPanel, Interfaces.IWidgetViewer
    {
        Xml.WidgetLocation widgetLocation = null;
        Xml.WidgetSize widgetSize = null;
        //Xml.WidgetFont widgetFont = null;
        //Xml.Appearance appearance = null;
        //player.Playlist = new System.Collections.ObjectModel.ObservableCollection<PlaylistItem>();
        //PlaylistItem list = new PlaylistItem();
        //list.MediaSource = new Uri("http://smf.vertigo.com/videos/wildlife.wmv");
        //player.Playlist.Add(list);
        string parent;
        string type;
        string text;
        TextBox label = new TextBox();

        public MediaViewer()
        {
            //System.Windows.Browser.HtmlPage.Window.Alert("viewer costruttore");
            Build();
        }

        private void Build()
        {
            //System.Windows.Browser.HtmlPage.Window.Alert("viewer build");
            //SMFPlayer player = new SMFPlayer();
            DockPanel.SetDock(this, Dock.Top);
            this.LastChildFill = true;
            //label.IsReadOnly = true;
            //DockPanel panel = new DockPanel();
            //panel.LastChildFill = true;
            //panel.Children.Add(label);
            //panel.Children.Add(player);

        }


        #region IWidgetViewer Membri di

        public Xml.WidgetLocation WidgetLocation
        {
            get
            {
                //return widgetLocation == null ? new Xml.WidgetLocation(Int32.Parse(base.GetValue(Canvas.LeftProperty).ToString()), Int32.Parse(base.GetValue(Canvas.TopProperty).ToString()), "", "") : widgetLocation;
                return null;
            }
            set
            {
                widgetLocation = value;
                Canvas.SetLeft(this, widgetLocation.X);
                Canvas.SetTop(this, widgetLocation.Y);
            }
        }

        public  Xml.WidgetSize WidgetSize
        {
            get
            {
                //return widgetSize == null ? new Xml.WidgetSize(Int32.Parse(this.GetValue(WidthProperty).ToString()), Int32.Parse(this.GetValue(HeightProperty).ToString())) : widgetSize;
                return widgetSize;
            }
            set
            {
                widgetSize = value;
                this.Height = widgetSize.Height;
                this.Width = widgetSize.Width;
            }
        }

        public string Name
        {
            get
            {
                return label.Text;
            }
            set
            {
                label.Text = value;
            }
        }

        public string WidgetParent
        {
            get
            {
                return parent == null ? base.Parent.ToString() : parent;
            }
            set
            {
                this.parent = value;
            }
        }

        public string Type
        {
            get
            {
                return type == null ? base.GetType().ToString() : type;
            }
            set
            {
                this.type = value;
            }
        }

        public string Text
        {
            get
            {
                return this.text;
            }
            set
            {
                this.text = value;
            }
        }

        #endregion
    }
}
